
import request from '@/router/axios';

export const add = (data) => {
  return request({
    url: '/api/mes-product/mro/centerproduct/input',
    method: 'post',
    data
  });
};



//设置不良代码
export const setFailureCodes = (sequenceNumber, failureCode, workOrderNo) => {
  return request({
    url: `/api/mes-product/mro/centerproduct/set-failure-code?sequenceNumber=${sequenceNumber}&failureCode=${failureCode}&workOrderNo=${workOrderNo}`,
    method: 'post'
  });
};

//获取不良代码列表
export const getFailureCodeList = () => {
  return request({
    url: '/api/mes-product/mro/dict/list?dictType=FAILURE',
    method: 'get'
  });
};

//根据工序ID获取不良代码列表
export const getFailureCodeByIdList = (workstationRouteId) => {
  return request({
    url: `/api/mes-product/mro/dict/get-failure-code-list-by-workstation-route-id?workstationRouteId=${workstationRouteId}`,
    method: 'get'
  });
};


//产品序列号获取不良登记工序
export const productRoute = (params) => {
  return request({
    url: '/api/mes-product/product/get-productroute-by-sequence-number',
    method: 'get',
    params
  });
};



export const getLine = (workOrderId) => {
  return request({
    url: '/api/mes-product/productionline/list-Work-order',
    method: 'get',
    params: {
      workOrderId
    }
  });
};



export const getWorkOrderDetail = (workOrderNo) => {
  return request({
    url: '/api/mes-product/work-order/check-workOrderNo',
    method: 'get',
    params: {
      workOrderNo
    }
  });
};


/**
 * 获取产品序列号
 */
export const getProductSn = (params) => {
  return request({
    url: '/api/mes-product/product/check-sequence-number',
    method: 'get',
    params
  });
};


/**
 * 根据工单获取产线信息
 */
export const getWorkOrderLine = (params) => {
  return request({
    url: '/api/mes-product/product/line/list-by-work-order',
    method: 'get',
    params
  });
};
/**
 * 获取产线工位
 */
export const getStation = (lineId) => {
  return request({
    url: '/api/mes-product/station/list-by-lineId',
    method: 'get',
    params: {
      lineId
    }
  });
};


/**
 * 根据工单获取工序信息
 */
export const getWorkOrderRoute = (params) => {
  return request({
    url: '/api/mes-product/process/product-route/workorder-routes',
    method: 'get',
    params
  });
};

/**
 * 获取不良登记列表
 */
export const getFailureList = (current, size, params) => {
  return request({
    url: '/api/mes-product/mro-repair-register/page',
    method: 'get',
    params: {
      current,
      size,
      ...params
    }
  });
};

export const remove = (id) => {
  return request({
    url: '/api/mes-product/mro-repair-register/remove',
    method: 'get',
    params: {
      id,
    }
  })
}


export const submit = (data) => {
  return request({
    url: '/api/mes-product/mro-repair-register/register',
    method: 'post',
    data
  });
};


//不良代码验证
export const checkCode = (params) => {
  return request({
    url: '/api/mes-product/mro-dict/check-code',
    method: 'get',
    params: {
      ...params,
      dictType: 'BAD_PHENOMENON'
    }
  });
};
